/**
 * 
 */
package com.pentalog.common.test.spring.test;

import junit.framework.Assert;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.pentalog.common.bo.MultiDBService;
import com.pentalog.stock.dao.StockDao;
import com.pentalog.stock.model.Stock;

/**
 * @author tnguyenmanh
 * 
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/spring/config/BeanLocations.xml" })
public class HelloSpringTestWithJUnitRealDB extends
		AbstractTransactionalJUnit4SpringContextTests {

	@Autowired
	private MultiDBService multiDBService;

	@Autowired
	private StockDao stockDao;

	@Test
	public void testMe() {
		System.out.println("Hello from Spring test...");
	}

	@Test
	public void testForService() {
		Assert.assertNotNull(multiDBService);
		multiDBService.doSomeThingWithMultiDB();
	}

	@Test
	public void testForDaoOnDB1() {
		Assert.assertNotNull(stockDao);
		Stock stock = new Stock();
		stock.setStockCode("7668");
		stock.setStockName("HAIO");
		stockDao.save(stock);
		stock = stockDao.findByStockCode("7668");
		Assert.assertNotNull(stock);
	}

}
